class UserSettingsController < ApplicationController

  before_filter :authenticate

  def index    
  end
  
  def save_settings   
    @user.name = params[:user][:name] unless params[:user][:name].blank?
    @user.email = params[:user][:email] unless params[:user][:email].blank?
    @user.save
    render :action => :index
  end
  
  def new_password
    @user.password = nil
  end
  
  def change_password
    if @user.update_attributes({:password => params[:user][:password], :password_confirmation => params[:user][:password_confirmation]})
      @user.encrypt_password
      @user.save
      flash[:notice] = 'User was successfully saved.'
      redirect_to :action => :index
    else
      logger.info "Could not save user"
      render :action => :new_password
    end
  end
  
end
